var ALY = require('aliyun-sdk');
var sts = new ALY.STS({
      accessKeyId: 'APQDeuPPWlcGj1Q0',
      secretAccessKey: '11H2DnSot1Ov7oIFJ80ow7es27j8mx',
      endpoint: 'https://sts.aliyuncs.com',
      apiVersion: '2015-04-01'
    }
);

module.exports = function (req, res) {
  sts.getFederationToken({
    StsVersion: '1',
    Action: 'GetFederationToken',
    Name: 'admin',
    // policy 规则文档: http://docs.aliyun.com/#/pub/ram/ram-user-guide/policy_reference&struct_def
    Policy: '{"Version":"1","Statement":[{"Effect":"Allow", "Action":"*", "Resource":"*"}]}',
    DurationSeconds: 3000
  }, function (err, data) {
    if(err) {
      return res.send(500, err);
    }

    res.json(data);
  });
};